<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/12 0012
 * Time: 22:23
 */

namespace App\Http\Controllers\Transformers;


use App\Model\News;
use League\Fractal\TransformerAbstract;

class NewsTransformer extends TransformerAbstract
{
    protected $availableIncludes=['classify','user'];
public function transform(News $news){
    return [
        'id'=>$news->id,
        'title'=>$news->title,
        'brief'=>$news->brief,
        'content'=>$news->content
    ];
}
public function includeClassify(News $news){
    return $this->item($news->classify,new ClassifyTransformer());
}
public function includeUser(News $news){
    return $this->item($news->user,new UserTransformer());
}
}
